import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:zrjz/comm/base/base.dart';
import 'package:zrjz/comm/constants/constants.dart';
import 'package:zrjz/comm/utils/ex_widget.dart';
import 'package:zrjz/comm/utils/ext_dart.dart';

import 'package:zrjz/comm/widget/common_widget.dart';
import 'package:zrjz/comm/widget/my_text_view.dart';

import 'package:zrjz/router/page_router.dart';

import 'notification_enable_controller.dart';

/*
  是否接收消息推送
 */
class NotificationEnablePage extends BaseStatelessPage<NotificationEnableController>{
  NotificationEnablePage({super.key});

  //启动当前页面
  static void startInstance() {
    return Get.start(RouterPath.NOTIFICATION_ENABLE);
  }

  @override
  NotificationEnableController createRawController() {
    return NotificationEnableController();
  }

  @override
  void initState() {}

  @override
  Widget buildWidget(BuildContext context) {

    return Scaffold(
        backgroundColor: DarkThemeUtil.multiColors(ColorConstants.pageBg, darkColor: ColorConstants.darkBlackBg),
        appBar: CommonWidget.appBar(context, "消息推送设置".tr),
        body: SafeArea(
          bottom: true,
          top: false,
          //真正的 Content 布局
          child: Scrollbar(
            child: SingleChildScrollView(
              child: autoCtlGetBuilder(builder: (controller) {
                return Column(
                  mainAxisSize: MainAxisSize.max,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    ListTile(
                      title: MyTextView(
                        '系统推送设置',
                        textColor: DarkThemeUtil.multiColors(ColorConstants.black, darkColor: ColorConstants.white),
                        fontSize: 16,
                        isFontMedium: true,
                      ).onTap(() {
                        //打开应用设置
                        openAppSettings();
                      }),
                    ),
                    Divider(
                      color: DarkThemeUtil.multiColors(ColorConstants.dividerD9, darkColor: ColorConstants.darkBlackItemDivider),
                      height: 0.5,
                    ),
                    ListTile(
                      title: MyTextView(
                        '允许消息推送',
                        textColor: DarkThemeUtil.multiColors(ColorConstants.black, darkColor: ColorConstants.white),
                        fontSize: 16,
                        isFontMedium: true,
                      ),
                      trailing: CupertinoSwitch(
                        value: controller.isSelected,
                        onChanged: (value) {
                          controller.changed(value);
                        },
                      ),
                    ),
                  ],
                );
              }),
            ),
          ),
        ));
  }
}
